<?php
require_once("../../class2.php");
require_once(HEADERF);
		$user_id = USERID;
		$user_name = USERNAME;
require_once("./includes/require_all.php");

?>
<script>
	function insertFromURL(url,from,into) {
		$(into).load(url+' '+from);
	};
	function sendToURL(trans,url) {
		var text = $(trans).val();
		var taken = text.replace(/\\n/g, "✘");
		var answer = confirm(taken);
		if(answer) { $.post(url, { text: taken } ) };
	};
</script>
<?php

ramka("open");

if($user_rights['Approve']==1 OR (in_array($user_name, $adminss))){
CMS_activitySave("apall.php");
echo "<a href='http://playonbg.info/translations/cms/filestable.php?game=$CMS_game' style='font-size:18px;'>НАЗАД</a><br>";
echo "<center><h1><b>Чакащи одобрение</b></h1></center>";
if($_GET['game']) { unset($game_prefixes); $temp= explode("_",$translations_table); $game_prefixes[]= $temp[0]; }
foreach ($game_prefixes as $prefix) {
	$mysql= $prefix."_translations"; $mysql2= $prefix."_text";
	$waitings= mysql_query("SELECT * FROM $mysql WHERE status LIKE 'В процес на%' ORDER BY time DESC");
	$toname= mysql_fetch_array(mysql_query("SELECT game_name FROM admin_panel WHERE game_prefix='$prefix' LIMIT 1"));
	$gamename= $toname['game_name'];
	if (mysql_num_rows($waitings)>0) echo "<br><h1>".$gamename."</h1><br>";
	while($trans=mysql_fetch_array($waitings)) {
		$ids= "";
		$text= trim($trans['translation']); $user=$trans['user_name']; $filename=urlencode($trans['file_name']);
		$exploded= clear_array(explode("\n",$text));
			foreach($exploded as $temp) {
				$val= explode("=>",$temp); $ids.=$val[0]."*~*";
			} $ids=urlencode($ids);
		echo <<<HTML
			  <div style='border-top:1px dotted grey; border-bottom:1px dotted grey;'>
			  <div class='cmsRow1'>
				  <span class='dictYELLOW'>$trans[translator_name]</span>
				  <span class='dictGREEN'>$trans[time]</span>
				  <span style='float:right'>
				  <button type="button" title="Одобри" id="but1_$trans[id]" class="dictButton hoverGREEN dictGREY" style="display:inline;"
				  onClick="changeClass('but1_$prefix_$trans[id]', 'dictButton hoverGREEN dictGREEN'); changeClass('but2_$prefix_$trans[id]', 'dictButton hoverGREY dictGREY'); sendToURL('#text_$prefix_$trans[id]','ap_exec.php?game=$prefix&id=$trans[id]&updat=$CMS_game');">✔</button>
				  <button type="button" title="Чака одобрение" id="but2_$prefix_$trans[id]" class="dictButton hoverYELLOW dictYELLOW" style="display:inline;">⚠</button>
				  </span>
			  </div>
			  <textarea id='text_$prefix_$trans[id]' cols='91' rows='1' class='expand apview-textarea' style='border:0px;'
				onclick=insertFromURL('ap_tip.php?table=$mysql2&ids=$ids&file=$filename','#result','#tip_$prefix_$num')
				onblur=autoInsertMain('tip_$prefix_$num','')
				)>$text</textarea>
			  <div id='tip_$prefix_$num'></div>
			  </div><br>
HTML;
		$num++;
	}
}
echo "<h1></h1>";
}
else echo "<meta http-equiv=\"refresh\" content=\"0;http://playonbg.info\" />";
unset($waitings,$ids);

ramka("close");

require_once(FOOTERF);